<template>
	<view class="content">
		<view class="row list" style="justify-content: space-between;">
			<view class="col-6 label">
				姓名
			</view>
			<view class="col-18">
				<input type="text" class="t_right" v-model="objPage.name" placeholder="请输入姓名" />
			</view>
		</view>
		<view class="row list" style="justify-content: space-between;">
			<view class="col-6 label">
				手机号
			</view>
			<view class="col-18">
				<input type="text" class="t_right" v-model="objPage.mobile" placeholder="请输入手机号" />
			</view>
		</view>
		<view class="row list" style="justify-content: space-between;margin-top: 21rpx;">
			<view class="col-6 label">
				是否是本人
			</view>
			<view class="col-18 t_right">
				<switch @change="switchs" :checked="objPage.isOneself == 1"/>
			</view>
		</view>
		<view class="btn">
			<button type="primary" @click="save()">保存</button>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				objPage:{
					isOneself: 0,
					mobile: "",
					name: "",
				}
			}
		},
		methods:{
			switchs({detail}){
				this.objPage.isOneself = detail.value
			},
			async save(){
				let res = await this.$api.request(this.$api.user.addlist,this.objPage);
				if(res == undefined){
					this.$public.showToast('添加成功');
					setTimeout(()=>{uni.navigateBack()},800);
				}
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f5f5f5;
	}
	
	.content{
		padding-top: 21rpx;
	}
	.list{
		width: 92%;
		padding: 0 4%;
		background-color: #FFFFFF;
		height: 108rpx;
		line-height: 108rpx;
		border-bottom: 1px solid #ededed;
		color: #333333;
		input{
			width: 100%;
			height: 108rpx;
			line-height: 108rpx;
			color: #333333;
		}
	}
	.btn{
		width: 92%;
		padding: 0 4%;
		margin-top: 59rpx;
		button[type="primary"]{
			background-color: #6CBF30;
			height: 96rpx;
			line-height: 96rpx;
			border-radius: 48rpx;
		}
	}
</style>
